﻿#region Copyright ©2008-2010, Technische Universitaet Muenchen
// ====================================================================================================
//
// Last Changed by       $Author: then $
// Last Changed Date     $LastChangedDate: 2009-06-09 09:28:29 +0200 (Tue, 09 Jun 2009) $
// Last Changed Revision $Rev: 185 $
//
// ====================================================================================================
#endregion

using System.Windows.Controls;

namespace Tum.CollabXT
{
    /// <summary>
    /// Conversion workflow control interface.
    /// </summary>
    public interface IConversionWorkflow
    {
        /// <summary>
        /// Sets the state of the workflow control buttons.
        /// </summary>
        /// <param name="prevButtonClickable">Is the prev button clickable?</param>
        /// <param name="nextButtonClickable">Is the next button clickable?</param>
        void UpdateButtonState(bool prevButtonClickable, bool nextButtonClickable);

        /// <summary>
        /// Call this, if a valid processing has been created.
        /// </summary>
        void ValidateProcessing();

        /// <summary>
        /// Call this, if data, relevant to the processing, has changed -> no valid processing exists.
        /// </summary>
        void InvalidateProcessing();

        /// <summary>
        /// Equals a click on the "next" button.
        /// Button state and NextPageRequested are not checked during this action (disabled "next" button is ignored).
        /// </summary>
        void NextPage();

        /// <summary>
        /// Equals a click on the "prev" button.
        /// Button state and PrevPageRequested are not checked during this action (disabled "prev" button is ignored).
        /// </summary>
        void PreviousPage();
    }

    public class ConversionWorkflowPage : Page
    {
        /// <summary>
        /// Called to handle the workflow instance to the page.
        /// </summary>
        /// <param name="workflow">The belonging workflow.</param>
        public virtual void ReceiveWorkflowHandle(IConversionWorkflow workflow)
        { }

        /// <summary>
        /// A notification, called, wenn the user clicks 'next'.
        /// </summary>
        /// <returns>True, if the workflow is allowed to advance one step, false if not.</returns>
        public virtual bool NextPageRequested()
        {
            return true;
        }

        /// <summary>
        /// A notification, called, wenn the user clicks 'back'.
        /// </summary>
        /// <returns>True, if the workflow is allowed to go back one step, false if not.</returns>
        public virtual bool PrevPageRequested()
        {
            return true;
        }
    }

    /// <summary>
    /// Base class for a process provider configuration page.
    /// </summary>
    public class ProcessProviderConfigPage : ConversionWorkflowPage
    {
        /// <summary>
        /// When overridden in a class, this method is passed the belonging process provider.
        /// </summary>
        /// <param name="processProvider">Belonging process provider.</param>
        public virtual void ReceiveProviderHandle(IProcessProvider processProvider)
        { }
    }

    /// <summary>
    /// /// Base class for a tool provider configuration page.
    /// </summary>
    public class ToolProviderConfigPage : ConversionWorkflowPage
    {
        /// <summary>
        /// When overridden in a class, this method is passed the belonging tool provider.
        /// </summary>
        /// <param name="toolProvider">Belonging tool provider.</param>
        public virtual void ReceiveProviderHandle(IToolProvider toolProvider)
        { }
    }
}
